package butines.common.graph;


public class Edge {

	private Node from;
	private Node to;
	private double cost;
	
	public Edge(Node from, Node to, double cost) {
		if (from == null) {
			throw new IllegalArgumentException("from is null");
		}
		if (to == null) {
			throw new IllegalArgumentException("to is null");
		}
		if (cost < 0) {
			throw new IllegalArgumentException("cost can not be negative");
		}
		this.from = from;
		this.to = to;
		this.cost = cost;
	}

	public Node getFrom() {
		return from;
	}

	public Node getTo() {
		return to;
	}

	public double getCost() {
		return cost;
	}

	public String toString() {
		return "[ " + from.getId() + " - " + to.getId() + " ]";
	}
	
//	public void remove() {
//		from.getEdges().remove(this);
//		from = null;
//	}
//	
//	public void reverseRemove() {
//		Edge edge = to.getEdges().get(from);
//		edge.remove();
//		edge.to = null;
//	}
	
}